package com.zy.gmall.realtime.util;

import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

public class KeyWordUtil {
    public static List<String> analyze(String text){
        List<String> list = new ArrayList<>();//存放row
        Lexeme lexeme;//介石嘛
        try (StringReader reader = new StringReader(text)) {
            IKSegmenter segmenter = new IKSegmenter(reader, true);
            while ((lexeme = segmenter.next()) != null) {
                list.add(lexeme.getLexemeText());
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return list;
    }

    public static void main(String[] args) {
        List<String> list = analyze("小米手机华为电脑一个大保健");
        for (String s : list) {
            System.out.println(s);
        }
    }

}
